import {createSlice,PayloadAction} from '@reduxjs/toolkit'


export type UserInfoType = {
    username:string,
    nickname:string
}

const InitialState_UserInfo:UserInfoType = {
    username:'',
    nickname:''
} 

const UserInfoSlice = createSlice({
    name:'UserInfoSlice',
    initialState:InitialState_UserInfo,
    reducers:{
        setUserInfo(state:UserInfoType,action:PayloadAction<UserInfoType>){
            const data = action.payload
            return {...data}
        },
        resetUereInfo(state:UserInfoType){
            return InitialState_UserInfo
        }
    }
})

export const {setUserInfo,resetUereInfo} = UserInfoSlice.actions

export default UserInfoSlice.reducer